const express = require('express')
const router = express.Router()
const userValidator = require('../../validator/user')
const userCtrl = require('../../controller/user')

// 用户登录
router.post('/login', userValidator.login, userCtrl.login)

// 用户注册
router.post('/register', userValidator.register, userCtrl.register)

// 获取所有用户
router.get('/', userCtrl.allUser)

// 获取当前登录用户
router.get('/current', userCtrl.getCurrentUser)

// 更新当前登录用户
router.put('/:userId', userCtrl.updateCurrentUser)

// 删除用户
router.delete('/:userId', userCtrl.deleteUser)

module.exports = router
